﻿using EntityModels.Entities;
using Microsoft.EntityFrameworkCore;

namespace EntityModels.DbContexts
{
    /// <summary>
    /// 全局查询过滤器
    /// </summary>
    public class QueryFilterDbContext : DbContext
    {
        public DbSet<QueryFilterEntity> QueryFiltersEntities => Set<QueryFilterEntity>();


        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<QueryFilterEntity>(
                b =>
                {
                    b.Property(q => q.IsDeleted)
                    .HasDefaultValue(false);

                    b.HasQueryFilter(q => q.IsDeleted == false);
                });
        }

    }
}
